package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.StoreBean;
import com.project.dto.SupplierDto;
import com.project.service.IStoreService;
import com.project.util.SupplierThreadLocal;
import com.project.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("store")
public class StoreController {
    @Autowired
    private IStoreService storeService;
    @RequestMapping("cutByItem")
    public ResultVo cutByItem(Integer pageNO, String goodsName, String type, String brand) {
        SupplierDto loginUser = SupplierThreadLocal.getSupplier();
        IPage<StoreBean> ip = storeService.cutByItem(pageNO, goodsName, type, brand, loginUser.getId());
        return ResultVo.ok(ip);
    }
    @RequestMapping("delete")
    public ResultVo delete(Long id) {
        storeService.delete(id);
        return ResultVo.ok();
    }
    @RequestMapping("findAllType")
    public ResultVo findAllType() {
        List<String> type = storeService.findAllType();
        return ResultVo.ok(type);
    }
    @RequestMapping("findAllBrand")
    public ResultVo findAllBrand() {
        List<String> b = storeService.findAllBrand();
        return ResultVo.ok(b);
    }
    @RequestMapping("updateNum")
    public ResultVo updateNum(Long goodsInfoId, Integer num) {
        storeService.updateNum(goodsInfoId, num);
        return ResultVo.ok();
    }
}
